#include <SimulationCore/GDC.h>
#include <SimulationCore/GCC.h>
#include <SimulationCore/Defines.h>
namespace SimulationCore
{
    GCC GDC::toGCC(bool isEllipsoid) const
    {
        double e = isEllipsoid ? GDC2GCC_E2: GDC2GCC_E1;
        double N = EARTH_RADIUS/ sqrt(1.0 - pow(e,2) * pow(sin(m_latitude * DEG_TO_RAD), 2));
        double x = (N + m_altitude) * cos(m_latitude * DEG_TO_RAD) * cos(m_longitude * DEG_TO_RAD);
        double y = (N + m_altitude) * cos(m_latitude * DEG_TO_RAD) * sin(m_longitude * DEG_TO_RAD);
        double z = (N * (1 - pow(e, 2)) + m_altitude) * sin(m_latitude * DEG_TO_RAD);
        return GCC(x, y, z);
    }
}